package org.lc.design.samples.case2;

import java.util.HashMap;
import java.util.Map;

/**
* 缓存管理器单例
* @author lc
* @date 2024/7/8
*/
public class CacheManager {

    private static CacheManager instance;

    private Map<String, Object> cache;

    private CacheManager() {
        cache = new HashMap<>();
    }

    public static CacheManager getInstance() {
        if(instance == null) {
            instance = new CacheManager();
        }
        return instance;
    }

    public void set(String key, Object value) {
        cache.put(key, value);
    }

    public Object get(String key) {
        return cache.get(key);
    }

    public void remove(String key) {
        cache.remove(key);
    }

}
